module game {

    export class GameContainer extends egret.DisplayObjectContainer {

        private normalScene: scene.NormalGameScene;

        public constructor() {
            super();
        }

        private hideAll(): void {
            manager.DisplayManager.remove(this.normalScene);
        }

        private gameType: number;
        private level: number;

        public update(data: any): void {
            this.onPlay();
        }

        private onPlay(): void {
            this.hideAll();

            this.playNormalGame()
        }

        private playNormalGame(): void {
            this.hideAll();
            if (this.normalScene == null) {
                this.normalScene = new scene.NormalGameScene();
            }
            this.addChild(this.normalScene);
        }

        public commit(score: number): void {
            if (!manager.GameManager.isProduct) {
                return;
            }
            egret.log("提交分数");
            let data = {
                "key": "score",
                "value": score.toString(),
            };
            let scoreData = [data];
            let openDataContext = wx.getOpenDataContext();
            openDataContext.postMessage({
                command: page.PkFriendPage.Only_Submit_Score,
                scoreData: scoreData,
            });
        }

    }

}